package com.example.demo.sharding.filter;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 类描述:
 * 自定义注解的切面；
 *
 * @author zhanglei
 * @date 2019/3/8 14:10
 **/

@Component
@Aspect
@Order(0)
@Slf4j
public class MeiZuInterceptor {

    @Pointcut("@annotation(com.example.demo.sharding.annotation.MeiZu)")
    public void aopPoint() {
        System.out.println("aop...");
    }

    @After("aopPoint()")
    public void afterRoute() {
    }

    @Before("aopPoint()")
    public void doRoute(JoinPoint jp) throws NoSuchMethodException {
        Object target = jp.getTarget();
        Signature signature = jp.getSignature();
        Object[] args = jp.getArgs();

        log.info("meizu==========");
        log.info(target.toString());
        log.info(signature.toString());
        log.info(args.toString());

    }

}
